home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 February / EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso / earcd / midi / gfft.lha / gfft-2.03 / source / gfft-2.03-source.lha / bcommand.c < prev    next >
C/C++ Source or Header  |  1996-01-02  |  3KB  |  103 lines

  1. /***************************************************************************
  2.  *          Copyright (C) 1994  Charles P. Peterson                  *
  3.  *         4007 Enchanted Sun, San Antonio, Texas 78244-1254             *
  4.  *              Email: Charles_P_Peterson@fcircus.sat.tx.us                *
  5.  *                                                                         *
  6.  *          This is free software with NO WARRANTY.                  *
  7.  *          See gfft.c, or run program itself, for details.              *
  8.  *              Support is available for a fee.                      *
  9.  ***************************************************************************
  10.  *
  11.  * Program:     gfft--General FFT analysis
  12.  * File:        bcommand.c
  13.  * Purpose:     process batch (i.e. shell) commands (noninteractively)
  14.  * Author:      Charles Peterson (CPP)
  15.  * History:     4-November-1993 CPP; Created.
  16.  * Comment:     error not caught here; must be caught by caller
  17.  *              Special logic: If a READ command is given for which there
  18.  *               is no following OK, GO, or WORKBENCH command, an OK command
  19.  *               is executed before return by default.  (Thus, OK is not
  20.  *               required in batch mode.)
  21.  */
  22.  
  23. #include <string.h>
  24. #include "gfft.h"
  25.  
  26. extern Name_Info_St Gfft_Command[];
  27.  
  28. void batch_command (int argc, char *argv[])
  29. {
  30.     int ntoken;
  31.     BOOLEAN ok_before_exit = FALSE;
  32.     Name_Info_St *command_invoked;
  33.  
  34.     for (ntoken = 1; ntoken < argc; ntoken++)
  35.     {
  36.     /*
  37.      * Filter out 'set' commands
  38.      */
  39.     Name_Info_St *name = identify_name (argv[ntoken], Gfft_Command, 
  40.                        FALSE);
  41.     if (!strcmp (name->full_string, "Set"))
  42.     {
  43.         continue;
  44.     }
  45.     /*
  46.      * Now see if the FOLLOWING
  47.      * token is a command too.  If not, it must be an argument to this one.
  48.      */
  49.     if (ntoken+1 < argc)
  50.     {
  51.         if (!identify_name (argv[ntoken+1], Gfft_Command, FALSE))
  52.         {
  53.         /*
  54.          * This command has one argument
  55.          */
  56.         strcpy (Command, argv[ntoken]);
  57.         strcat (Command," ");
  58.         strcat (Command, argv[ntoken+1]);
  59.         ntoken++;
  60.         }
  61.         else
  62.         {
  63.         strcpy (Command, argv[ntoken]);
  64.         }
  65.     }
  66.     else
  67.     {
  68.         strcpy (Command, argv[ntoken]);
  69.     }
  70.     command_invoked = invoke_method (Command, Gfft_Command);
  71.     if ( !strcmp (command_invoked->full_string, "Read"))
  72.     {
  73.         ok_before_exit = TRUE;
  74.     }
  75.     else if ( !strcmp (command_invoked->full_string, "Write"))
  76.     {
  77.         ok_before_exit = TRUE;
  78.     }
  79.     else if ( !strcmp (command_invoked->full_string, "Append"))
  80.     {
  81.         ok_before_exit = TRUE;
  82.     }
  83.     else if ( !strcmp (command_invoked->full_string, "OK"))
  84.     {
  85.         ok_before_exit = FALSE;
  86.     }
  87.     else if ( !strcmp (command_invoked->full_string, "Go"))
  88.     {
  89.         ok_before_exit = FALSE;
  90.     }
  91. #ifdef AMIGA
  92.     else if ( !strcmp (command_invoked->full_string, "Workbench"))
  93.     {
  94.         ok_before_exit = FALSE;
  95.     }
  96. #endif
  97.     }
  98.     if (ok_before_exit)
  99.     {
  100.     ok (NullString);
  101.     }
  102. }
  103.